package com.boot.start.config.exception;

import com.boot.start.config.result.StatusCode;
import lombok.Getter;
import lombok.Setter;

/**
 * @author 墨龙吟
 * @version 1.0.0
 * @ClassName SystemException.java
 * @Email 2354713722@qq.com
 * @Description 系统异常
 * @createTime 2020年05月18日 - 23:22
 */
@Setter
@Getter
public class SystemException extends RuntimeException{

    private static final long serialVersionUID = 552379584372493964L;

    /** 错误编码 */
    private String errCode;

    /** 错误信息 */
    private String errMsg;

    /**
     *
     * @param errCode  错误状态码
     * @param errMsg   错误信息
     */
    public SystemException(String errCode, String errMsg) {
        super(errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }


    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public SystemException(StatusCode resultCode) {
        super(resultCode.getMsg());
        this.errMsg = resultCode.getMsg();
        this.errCode = resultCode.getCode();
    }


}
